﻿<controls:ChildWindow
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
           xmlns:tlk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
           xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
           x:Class="Candy.GeneEditWindow"
           xmlns:clr="clr-namespace:System;assembly=mscorlib"
           Width="787" Height="410" 
           Title="GeneEditWindow">
    <controls:ChildWindow.Style>
        <StaticResource ResourceKey="ChildWindowStyleChromeless"/>
    </controls:ChildWindow.Style>
    <Border Margin="0" BorderBrush="{StaticResource Accent}" BorderThickness="1" >
        <Grid x:Name="LayoutRoot" Background="{StaticResource ControlBackgroundDark}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>

                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <Button x:Name="CancelButton" Command="{Binding CancelEdit}" Content="Cancel"  Width="75" HorizontalAlignment="Right" Margin="0,8,8,8" Grid.Row="10" Grid.Column="1" />
            <Button x:Name="OKButton" Content="OK" Command="{Binding Save}" Width="75" HorizontalAlignment="Right" Margin="0,8,90,8" Grid.Row="10" Grid.Column="1" />
            <TextBlock TextWrapping="Wrap" Text="Gene Editor" FontSize="{StaticResource HeaderFontSize}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="8,1,0,4" Height="28" Width="111"/>
            <TextBlock HorizontalAlignment="Left" Margin="8,4,0,4" TextWrapping="Wrap" VerticalAlignment="Center" Grid.Row="1" Text="Identifier"/>
            <TextBox Grid.Row="2" TextWrapping="Wrap" Text="{Binding Entity.GeneIdentifier, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}" VerticalAlignment="Center" Margin="8,4" Height="24"/>
            <TextBlock HorizontalAlignment="Left" Margin="8,4,0,4" TextWrapping="Wrap" Text="Name" VerticalAlignment="Center" Grid.Row="1" Grid.Column="1"/>
            <CheckBox Content="Auto Name" HorizontalAlignment="Left" Margin="68,4,0,4" Grid.Row="1" VerticalAlignment="Center" IsChecked="{Binding Entity.AutogeneratedName, Mode=TwoWay}" Grid.Column="1" Style="{StaticResource DefaultCheckBox}"/>
            <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Species" VerticalAlignment="Center" Grid.Row="3" Margin="8,4,0,4"/>
            <TextBox IsEnabled="{Binding Entity.AutogeneratedName, Converter={StaticResource ResourceKey=NegateConverter}}" Margin="8,4" Grid.Row="2" TextWrapping="Wrap" Text="{Binding Entity.Name, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}" VerticalAlignment="Center" Grid.Column="1" Height="24"/>

            <sdk:AutoCompleteBox SelectedItem="{Binding Genotype, Mode=TwoWay}" Grid.Row="4" VerticalAlignment="Center" ItemsSource="{Binding Genotypes.Genotypes, Source={StaticResource Locator}}" FilterMode="Contains" IsTextCompletionEnabled="False" ValueMemberPath="FullName" Margin="8,4" >
                <sdk:AutoCompleteBox.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" MinWidth="28"/>
                                <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                            <TextBlock Text="{Binding Name}" Grid.Column="0"/>
                            <StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Stretch">
                                <TextBlock Text="{Binding Genus}"/>
                                <TextBlock Text="{Binding Species, StringFormat=.\{0\}}"/>
                            </StackPanel>
                        </Grid>
                    </DataTemplate>
                </sdk:AutoCompleteBox.ItemTemplate>
            </sdk:AutoCompleteBox>
            <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Database" VerticalAlignment="Center" Grid.Row="3" Margin="8,4,0,4" Grid.Column="1"/>
            <sdk:AutoCompleteBox Margin="8,4" Grid.Row="4" VerticalAlignment="Center" IsEnabled="False" Grid.Column="1" />
            <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Sequence" VerticalAlignment="Center" Grid.Row="7" Margin="8,4,4,4"/>
            <TextBox Grid.Row="8" TextWrapping="Wrap" Text="{Binding Entity.ProteinSequence, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}" Margin="8,4" Grid.ColumnSpan="2" FontFamily="Segoe UI Mono"/>
        </Grid>
    </Border>
</controls:ChildWindow>